//
//  TwentyNineViewController.m
//  项目二
//
//  Created by rimi on 16/5/17.
//  Copyright © 2016年 objective. All rights reserved.
//

#import "TwentyNineViewController.h"
#import "TabBarViewController.h"
#import "Datai5ViewController.h"
#import "InformationCenter.h"
@interface TwentyNineViewController ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic,strong)NSArray *dataSouce;
@property (nonatomic,strong)UITableView *tabView;
@property(nonatomic,strong)TabBarViewController *tabBarViewController;
@end

@implementation TwentyNineViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    
    [self initUIdataSource];
    [self initUIInterface];
}

- (void)initUIdataSource{
    _dataSouce = @[@"QQ钱包",@"激活会员",@"个性装扮",@"我的收藏",@"我的相册",@"我的文件"];
}
-(void)initUIInterface{
    [self.view addSubview:self.tabView];
    /**创建标签控制器*/
    _tabBarViewController = [TabBarViewController new];
    /**把标签控制器作为根视图控制器*/
    [self addChildViewController:_tabBarViewController];
    [self.view addSubview:_tabBarViewController.view];
}
#pragma mark- UITableViewDelegate,UITableViewDataSource
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return _dataSouce.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell *cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"111"];
    cell.textLabel.text = _dataSouce[indexPath.row];
    return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
/**隐藏菜单*/
    _tabBarViewController.view.center = CPM(CENTER_X, CENTER_Y);
    _tabBarViewController.view.transform = CGAffineTransformIdentity;
    /**更新菜单显示状态*/
    GET_DEFAULT_INFORMATIONCENTER.ShowMenuView = NO;
    /**获取标签控制器当前的导航控制器*/
    UINavigationController *nc =(UINavigationController *)_tabBarViewController.selectedViewController;
    /**创建详情控制器*/
    Datai5ViewController *datailVc = [[Datai5ViewController alloc]init];
    datailVc.title = _dataSouce[indexPath.row];
    datailVc.view.backgroundColor = [UIColor whiteColor];
    /**跳转*/
    [nc pushViewController:datailVc animated:YES];
    /**隐藏标签栏*/
    _tabBarViewController.tabBar.hidden = YES;
}
#pragma mark - GET
-(UITableView *)tabView{
    if (!_tabView) {
        _tabView = [[UITableView alloc]initWithFrame:CRM(20, 100, 100, 280) style:UITableViewStylePlain];
        _tabView.delegate = self;
        _tabView.dataSource = self;
        /**边框宽度*/
        _tabView.layer.borderWidth = 1.0f;
        /**边角圆度*/
        _tabView.layer.cornerRadius = 5.0f;
        /**边框阴影度*/
        _tabView.layer.masksToBounds = YES;
        [_tabView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"111"];
    }
    return _tabView;
}
@end
